package com.isoftstone.demo.flexigrid.controller;

import com.isoftstone.demo.flexigrid.entity.FlexigridDemo;
import com.isoftstone.demo.flexigrid.service.FlexigridDemoServie;
import com.isoftstone.services.base.RespBaseController;
import org.springframework.web.bind.annotation.*;

/**
 * flexigridDemo的controller层
 * <br>
 *
 * @author WenHaoJiong
 * @version [版本号, 2017年11月29日 15:08]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@RestController
@RequestMapping("/flexigrid")
public class FlexigridDemoController
    extends RespBaseController<FlexigridDemoServie>
{
    @Override
    public Long getModuleId()
    {
        return null;
    }


    @PostMapping
    public String save(FlexigridDemo model) throws Exception {
        // 操作对象（用于生成日志）
        Operation operation =
                new Operation("log.flexigrid.add").setMsgArgs(model.getAttribute1());
        // 执行业务、生成日志、返回Json
        return respSuccess(() -> service.save(model), operation);
    }

    @DeleteMapping("/{id}")
    public String del(@PathVariable Integer id) throws Exception {
        // 操作对象（用于生成日志）
        Operation operation =
                new Operation("log.flexigrid.delete");
        // 执行业务、生成日志、返回Json
        return respSuccess(() -> service.delete(id), operation);
    }
}
